﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Tetris
{
    [Serializable]
    public class LeftL : Shape
    {
        //global number of state for the shape
        public static int NbState = 4;

        /// <summary>
        /// basic constructor used when we deserialize
        /// </summary>
        public LeftL() : base()
        {
            points.Clear();
        }

        /// <summary>
        /// Basic constructor
        /// </summary>
        public LeftL(bool test): base()
        {
            points[1].X=3;
            points[1].Y=2;
            points[0].X=4;
            points[0].Y=2;
            points[3].X=4;
            points[3].Y=0;
            points[2].X=4;
            points[2].Y=1;
            state = 1;
        }

        /// <summary>
        /// Organized how the leftL will rotate according to its current state
        /// </summary>
        /// <param name="sens">Shape.COUNTCLOCKWISE or Shape.CLOCKWISE</param>
        public override void rotate(int sens)
        {
            //check that 0=>state<=4
            if (state < 1) this.state = Arrow.NbState;
            if (state > Arrow.NbState) this.state = 1;

            switch (state)
            {
                case 1:
                    points[1].X=points[1].X + 1 ;
                    points[1].Y=points[1].Y -(1*sens);
                    points[2].X=points[2].X +(1*sens);
                    points[2].Y=points[2].Y +1 ;
                    points[3].X=points[3].X +(2*sens);
                    points[3].Y=points[3].Y +2 ;
                    this.state += sens; 
                    break;

                case 2:
                    points[1].X=points[1].X +(1*sens);
                    points[1].Y=points[1].Y +1 ;
                    points[2].X=points[2].X -1 ;
                    points[2].Y=points[2].Y +(1*sens);
                    points[3].X=points[3].X -2 ;
                    points[3].Y=points[3].Y +(2*sens);
                    this.state += sens;
                    break;

                case 3:
                    points[1].X=points[1].X -1 ;
                    points[1].Y=points[1].Y +(1*sens);
                    points[2].X=points[2].X -(1*sens);
                    points[2].Y=points[2].Y -1 ;
                    points[3].X=points[3].X -(2*sens);
                    points[3].Y=points[3].Y -2 ;
                    this.state += sens;
                    break;

                case 4:
                    points[1].X=points[1].X -(1*sens);
                    points[1].Y=points[1].Y -1 ;
                    points[2].X=points[2].X +1 ;
                    points[2].Y=points[2].Y -(1*sens);
                    points[3].X=points[3].X +2 ;
                    points[3].Y=points[3].Y -(2*sens);
                    this.state += sens;
                    break;

            }
        }
    }
}
